#include <stdio.h>
#define M 4
#define N 15
int a[N] = {1, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3};

void swap(int *x, int *y) {
    int temp = *x;
    *x = *y;
    *y = temp;
}

void permute(int start) {
    if (start == M) {
        for (int i = 0; i < M; i++) {
            printf("%d ", a[i]);
        }
        printf("\n");
        return;
    }

    for (int i = start; i < N; i++) {
        swap(&a[start], &a[i]);
        permute(start + 1);
        swap(&a[start], &a[i]);
    }
}

int main(void) {
    permute(0);
    return 0;
}